const cloud = require('wx-server-sdk');
cloud.init({
  env:"xiaotiao-6gcr9hxy3d8aa90f"
});
const db = cloud.database();
exports.main = async (event, context) => {
  var openid = event.openid;
  return await db.collection("tempUserInfo")
  .where({
    openid:openid
  })
  .get().then(res=>{
    if(ress.data.length==0){
      db.collection("tempUserInfo")
      .add({
        data:{
          _openid:openid
        }
      }).then(res=>{
        console.log("添加成功")
      })
    }
  })
  .catch(res=>{
    console.log("已经存在啦")
  })
}